From 9c72383261ea7b90fe54c0ee0212446b7c1d013a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sat, 8 Nov 2008 23:20:29 +0000 Subject: [PATCH] use the lookup tables to speed up the conversion 8still error of 0.002677 * extensions/gegl-fixups.c: (conv_rgbAF_lrgba8): use the lookup tables to speed up the conversion 8still error of 0.002677 though). svn path=/trunk/; revision=354 --- ChangeLog | 5 +++++ extensions/gegl-fixups.c | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83c1728..87a957e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-08 Øyvind Kolås + + * extensions/gegl-fixups.c: (conv_rgbAF_lrgba8): use the lookup tables + to speed up the conversion 8still error of 0.002677 though). + 2008-11-06 Øyvind Kolås * extensions/gegl-fixups.c: (conv_rgbAF_rgbaF), diff --git a/extensions/gegl-fixups.c b/extensions/gegl-fixups.c index 72da8ba..20948cb 100644 --- a/extensions/gegl-fixups.c +++ b/extensions/gegl-fixups.c @@ -488,6 +488,7 @@ conv_rgbAF_rgbaF (unsigned char *srcc, } + static long conv_rgbAF_lrgba8 (unsigned char *srcc, unsigned char *dstc, @@ -500,13 +501,18 @@ conv_rgbAF_lrgba8 (unsigned char *srcc, while (n--) { float alpha = src[3]; - float recip = (1.0/alpha)*255.0; + float recip = (1.0/alpha); if (alpha < 0.00001) - recip = 0.0; - dst[0] = (src[0] * recip); - dst[1] = (src[1] * recip); - dst[2] = (src[2] * recip); - dst[3] = alpha*255.0; + { + dst[0] = dst[1] = dst[2] = dst[3] = 0; + } + else + { + dst[0] = table_F_8[gggl_float_to_index16 (src[0] * recip)]; + dst[1] = table_F_8[gggl_float_to_index16 (src[1] * recip)]; + dst[2] = table_F_8[gggl_float_to_index16 (src[2] * recip)]; + dst[3] = table_F_8[gggl_float_to_index16 (alpha)]; + } src += 4; dst += 4; } -- 2.30.2